<script setup lang="ts">
import {computed, inject} from "vue";

const colGap = inject('colGap')
const rowGap = inject('rowGap')
const record = inject('record')
const crudRef = inject('crudRef')
const columnsDist = inject('columnsDist')//全部字典

const getDict = (type,index,dataIndex)=>{
  // let dict = crudRef.value.getColumnService().getDictService(index).getRawDictData()
  // for (const dictKey in dict) {
  //   if(dict[dictKey].value == dataIndex){
  //     return dict[dictKey].label
  //   }
  // }
  // return
if(type=='dicthelpApi_service'){
  let dict = columnsDist.value[index].data
  for (const dictKey in dict) {
    if(dict[dictKey].id == dataIndex){
      return dict[dictKey].name
    }
  }
}else if(type=='dictObj'){
  let dict = columnsDist.value.dictObj.data[index]
  for (const dictKey in dict) {
    if(index=='countrys'){
      if(dict[dictKey].key == dataIndex){
      return dict[dictKey].title+'-'+record.value.country
    }
    }else{
      if(dict[dictKey].key == dataIndex){
      return dict[dictKey].title
    }
    }
   
  }
}
  return
}
const serviceName = computed(()=>getDict('dicthelpApi_service','dicthelpApi_service',record.value.service_id))
const countryName = computed(()=>getDict('dictObj','countrys',record.value.country))
const statusDesc = computed(()=>getDict('dictObj','shipment_parcel_type',record.value.status))
</script>

<template>
  <a-grid-item :span="24">
    <a-grid :cols="{ xs: 1, sm: 2, md: 3, lg: 4}" :colGap="colGap" :rowGap="rowGap">
      <a-grid-item ><a-card><a-card-meta :title="record.service?.name" description="服务类型"></a-card-meta></a-card></a-grid-item>
      <a-grid-item ><a-card><a-card-meta :title="countryName" description="发往国家"></a-card-meta></a-card></a-grid-item>
      <a-grid-item ><a-card><a-card-meta :title="record?.flow?.income??'--'" description="费用"></a-card-meta></a-card></a-grid-item>
      <a-grid-item ><a-card><a-card-meta :title="statusDesc" description="状态"></a-card-meta></a-card></a-grid-item>
    </a-grid>
  </a-grid-item>
</template>

<style scoped>

</style>